package com.huqing.icu.controller;

import com.huqing.icu.req.app.chatmessage.ChatCompletionReq;
import com.huqing.icu.service.IChatMessageService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

import java.util.HashMap;
import java.util.Map;
import java.util.Stack;

/**
 * @Description 对话消息接口
 * @Author huqing
 * @Date 2025/8/20 9:12
 **/
@Tag(name = "AI对话接口")
@RestController
@RequestMapping("/api/chat")
public class ChatMessageController {

    @Autowired
    private IChatMessageService iChatMessageService;

    @Operation(summary = "completion")
    @PostMapping(value = "/completion")
    public Flux<ChatResponse> completion(@RequestBody ChatCompletionReq chatCompletionReq, HttpServletRequest request) {
        //Long userId = checkAndGetUserId(request);
        Long userId = 9600L;
        chatCompletionReq.setChatSessionId(1L);
        return iChatMessageService.completion(chatCompletionReq, userId);
    }
}
